import pymysql
import pytest

from config.config import *


@pytest.fixture(scope="session", autouse=True)
def destroy_iiii():

    print("===== destroy_init fixture开始执行 =====")# 添加调试信息
    yield
    sqls = [
        'delete from sp_goods where goods_name = "大码牛仔裤+"'
    ]

    conn = pymysql.Connect(
        host=DB_HOST,
        port=DB_PORT,
        database=DB_DATABASE,
        user=DB_USER,
        password=DB_PASSWORD,
        charset="utf8",
        autocommit=True
    )

    cur = conn.cursor()

    for sql in sqls:
        cur.execute(sql)
    print("===== destroy_init fixture执行完成 =====")
    cur.close()

    conn.close()
